const express = require('express');
const router = express.Router();

router.get('/me', (req, res) => {
    res.json({
        payload: {
            id: '1001',
            name: '张三',
            username: 'sam',
            enterpriseName: '奇瑞销售股份有限公司',
            roles: ['销售顾问']
        }
    });
});

const codeMap = {
    'dcs-afterSales-expenseAdjustment': ['submit', 'update', 'abandon', 'approve', 'add', 'export', 'confirm', 'exportDetail', 'exportPi', 'reportFinance', 'confirmPi'],
    'dcs-afterSales-claim': ['submit', 'update', 'abandon', 'approve', 'add', 'export', 'return', 'querySearch', 'usedLabelPrint', 'adjust', 'queryExport', 'historyExport'],
    'dcs-afterSales-claimProformaInvoice': ['confirm', 'abandon', 'approve', 'export'],
    'dcs-afterSales-claimSettlement': ['update', 'confirmPI', 'finance', 'submit', 'invoice', 'abandon', 'approve', 'reSettlement', 'add', 'export', 'historySearch', 'moreApprove'],
    'dcs-afterSales-subClaim': ['submit', 'update', 'abandon', 'approve', 'add', 'export', 'return', 'historySearch', 'queryExport', 'historyExport'],
    'dcs-afterSales-usedPartDestory': ['update', 'abandon', 'submit', 'confirm', 'approve', 'print', 'add', 'export', 'confirmExport'],
    'dcs-afterSales-secondClaim': ['update', 'updateMore'],
    'dcs-afterSales-localPart': ['import', 'export', 'abandon'],
    'dcs-afterSales-dutyUnit': ['stop', 'start', 'update', 'add'],
    'dcs-afterSales-claimSupplier': ['stop', 'start', 'update', 'add'],
    'dcs-afterSales-partWarrantyCategory': ['add', 'update', 'abandon', 'export', 'import'],
    'dcs-afterSales-partWarrantyPolicy': ['add', 'update', 'abandon', 'enable'],
    'dcs-afterSales-vehicleSold': ['export', 'import', 'update'],
    'dcs-afterSales-vehicleMaintainRecord': ['import'],
    'dcs-afterSales-warrantyPolicy': ['add', 'update', 'abandon', 'enable'],
    'dcs-afterSales-exceptionInfoTransfer': ['add', 'update', 'submit', 'approve', 'improveResult', 'abandon', 'export'],
    'dcs-afterSales-salesInformation': ['import', 'export'],
    'dcs-afterSales-claimApply': ['submit', 'update', 'abandon', 'approve', 'add', 'export', 'return', 'historySearch', 'countersigner', 'queryExport'],
    'dcs-afterSales-workItem': [
        'add',
        'update',
        'import',
        'export',
        'enable',
        'disable',
        'setLaborHour',
        'setAssist',
        'category-add',
        'category-update',
        'category-enable',
        'category-disable',
        'category-import',
        'mode-manage',
        'advanced-export',
        'laborHour-import'
    ],
    'dcs-afterSales-dealerWorkItem': [
        'export',
        'import',
        'setAssist',
        'setLaborHour',
        'laborHour-import'
    ],
    'dcs-afterSales-faultMode': [
        'add',
        'update',
        'import',
        'export',
        'abandon',
        'category-add',
        'category-update',
        'category-abandon',
    ],
    'dcs-afterSales-faultItem': [
        'add',
        'update',
        'export',
        'abandon',
        'category-add',
        'category-update',
        'category-abandon',
    ],
    'dcs-afterSales-partServiceProperty': [
        'update',
        'batchCategory',
        'category-add',
        'category-update',
        'category-abandon',
        'assist-add',
        'assist-update',
    ],
    'dcs-afterSales-subClaimApply': ['submit', 'update', 'abandon', 'approve', 'add', 'export', 'historySearch', 'queryExport'],
    'dcs-afterSales-manucturerProductCategory': ['update', 'add', 'abandon', 'maintain'],
    'dcs-afterSales-secondClaimSummary': ['create', 'deliveryListExcel', 'costSumExcel', 'sumTableExcel', 'print', 'supplierSumExcel'],
    'dcs-afterSales-serviceActivity': ['add', 'update', 'abandon', 'publish'],
    'dcs-afterSales-secondaryDealerService': ['update', 'import'],
    'dcs-afterSales-dealerServiceInformation': ['update', 'export', 'import'],
    'dcs-afterSales-claimReason': ['update', 'abandon', 'add'],
    'dcs-afterSales-dutyUnitWarrantie': ['add', 'update', 'abandon', 'import'],
    'dcs-afterSales-dutyUnitReplace': ['add', 'update', 'abandon', 'import'],
    'dcs-afterSales-specialDutyUnitDetermine': ['add', 'update', 'abandon', 'import'],
    'dcs-afterSales-specialPartReplace': ['add', 'update', 'abandon', 'import'],
    'dcs-afterSales-qualityArbitration': ['add', 'update', 'abandon', 'import'],
    'dcs-afterSales-techShipment': ['add', 'update', 'abandon', 'import'],
    'dcs-afterSales-preClaimInfo': ['add', 'update', 'abandon', 'import'],
    'dcs-afterSales-goodWillBudget': ['add', 'update', 'abandon'],
    'dcs-afterSales-goodWill': ['add', 'update', 'abandon', 'opeation', 'submit'],
    'dcs-afterSales-goodwillSettlement': ['add', 'update', 'abandon', 'send', 'exportPi', 'upload', 'confirm', 'exportCover'],
    'dcs-afterSales-technologyActivity': ['add', 'export', 'update', 'addVIN', 'submit', 'abandon', 'publish', 'close', 'approve'],
    'dcs-afterSales-technologyActivityClaimSettlement': ['add', 'update', 'abandon', 'submit', 'approve', 'reSettlement', 'export'],
    'dcs-afterSales-technologyActivityDelayApply': ['add', 'update', 'submit', 'approve', 'abandon', 'export'],
    'dcs-afterSales-technologyActivityClaim': ['add', 'update', 'submit', 'abandon', 'export'],
    'dcs-afterSales-marketingActivityDeclare': ['add', 'update', 'approve', 'abandon', 'submit', 'takeEffect', 'report', 'effective'],
    'dcs-afterSales-marketingActivityReport': ['add', 'update', 'abandon', 'submit', 'confirm', 'upInvoice', 'invoiceConfirm', 'writeOff'],
    'dcs-afterSales-technicalSupport': ['add', 'update', 'export', 'abandon', 'submit', 'solved', 'close', 'transferToTechnicalCase', 'reply', 'reportAgain', 'feedback'],
    'dcs-afterSales-technicalCaseReport': ['add', 'update', 'abandon', 'approve', 'release', 'cancel', 'submit'],
    'dcs-afterSales-serviceSatisfactionSurvey': ['add', 'update', 'abandon', 'effective'],
    'dcs-afterSales-monthInformation': ['import'],
    'dcs-afterSales-serviceQuestionnaire': ['update', 'abandon', 'add'],
    'dcs-afterSales-socClaim': ['project', 'close', 'join'],
    'dcs-afterSales-soc': ['update', 'submit', 'close', 'release'],
};

router.get('/me/pages/:code', (req, res) => {
    const {
        code
    } = req.params;
    let payload = ['add', 'update', 'disable'];
    if(codeMap[code]) payload = codeMap[code];
    res.json({
        payload
    });
});

module.exports = router;
